import 'package:flutter/material.dart';
import 'package:get/route_manager.dart';
import 'package:yp/router.dart';
import 'package:yp/widgets/bottom_sheet.dart';
import 'package:yp/widgets/button_widget.dart';
import 'package:yp/widgets/dialog.dart';
import 'package:yp/widgets/index.dart';

class Collection extends StatefulWidget {
  const Collection({Key key}) : super(key: key);

  @override
  _CollectionState createState() => _CollectionState();
}

class _CollectionState extends State<Collection>
    with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin {
  AnimationController _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
        appBar: YPNavigationBar('部分功能', showBack: false),
        body: CustomScrollView(slivers: [
          SliverToBoxAdapter(
              child: Padding(
            padding: const EdgeInsets.all(16.0),
            child: Wrap(
              runSpacing: 16,
              spacing: 16,
              children: [
                EsOutLineButton('售后/退款', padding: EdgeInsets.all(8), onTap: () {
                  Get.toNamed(RouteConfig.afterMarket);
                }),
                EsOutLineButton('退款进度', padding: EdgeInsets.all(8), onTap: () {
                  Get.toNamed(RouteConfig.refundProgress);
                }),
                EsOutLineButton('申请售后', padding: EdgeInsets.all(8), onTap: () {
                  Get.toNamed(RouteConfig.applyAfterMarket);
                }),
                EsOutLineButton('售后详情', padding: EdgeInsets.all(8), onTap: () {
                  Get.toNamed(RouteConfig.afterMarketDetail);
                }),
                EsOutLineButton('物流追踪', padding: EdgeInsets.all(8), onTap: () {
                  Get.toNamed(RouteConfig.logisticsTracking);
                }),
                EsOutLineButton('结算商品列表', padding: EdgeInsets.all(8),
                    onTap: () {
                  Get.toNamed(RouteConfig.settleList);
                }),
                EsOutLineButton('取消订单', padding: EdgeInsets.all(8), onTap: () {
                  // Get.toNamed(RouteConfig.logisticsTracking);
                  YpBottomSheet.showSelect(
                      context,
                      [
                        '操作有误（商品/时间/地址选错了）',
                        '重复下单',
                        "不想要了",
                        "地址信息填写错误",
                        "商品降价",
                        "其他"
                      ],
                      title: "取消原因",
                      selectIndex: 2, clickCallback: (index, text, {info}) {
                    print(index);
                    print(text);
                  });
                }),
                EsOutLineButton('选择物流', padding: EdgeInsets.all(8), onTap: () {
                  // Get.toNamed(RouteConfig.logisticsTracking);
                  // YpBottomSheet.showText(context, ["退出登录"],
                  //     title: "请选择操作",
                  //     showRedText: true, clickCallback: (index, text) {
                  //   print(index);
                  //   print(text);
                  // });
                  YpBottomSheet.showText(context, ['中通', '圆通', "申通", "韵达"],
                      // title: "请选择",
                      // showRedText: true,
                      clickCallback: (index, text, {info}) {
                    print(index);
                    print(text);
                  });
                }),
                EsOutLineButton('选择支付方式', padding: EdgeInsets.all(8),
                    onTap: () {
                  YpBottomSheet.showPayWay(context, (index, text, {info}) {
                    print(index);
                    print(text);

                    Future.delayed(Duration(milliseconds: 300), () {
                      // Get.offAndToNamed(RouteConfig.paySuccess);
                    });
                  });
                }),
                EsOutLineButton('选择自提点', padding: EdgeInsets.all(8), onTap: () {
                  YpShowDialog.showPickUpStation(context, [
                    {'isSelect': false, 'name': '农业南路进水营业厅'},
                    {'isSelect': true, 'name': ''},
                    {'isSelect': false, 'name': '农业南路进水营业厅'},
                    {'isSelect': true, 'name': '农业南路进水营业厅'},
                    {'isSelect': false, 'name': ''}
                  ], (index, text, {info}) {
                    print(index);
                    print(text);
                  });
                }),
                EsOutLineButton('选择收货地址', padding: EdgeInsets.all(8),
                    onTap: () {
                  Get.toNamed(RouteConfig.addressList);
                }),
                EsOutLineButton('可用优惠券', padding: EdgeInsets.all(8), onTap: () {
                  YpBottomSheet.showCoupon(context, [
                    {'isSelected': true, 'amount': 30},
                    {'isSelected': false, 'amount': 50},
                    {'isSelected': false, 'amount': 50},
                    {'isSelected': false, 'amount': 150},
                    {'isSelected': false, 'amount': 5},
                    {'isSelected': false, 'amount': 5},
                    {'isSelected': false, 'amount': 5},
                    {'isSelected': false, 'amount': 5},
                    {'isSelected': false, 'amount': 80}
                  ], (index, text, {info}) {
                    print(index);
                    print(text);

                    Future.delayed(Duration(milliseconds: 300), () {
                      // Get.offAndToNamed(RouteConfig.paySuccess);
                    });
                  });
                }),
              ].toList(),
            ),
          )),
          SliverToBoxAdapter(
              child: Column(
            children: [],
          ))
        ]));
  }

  @override
  bool get wantKeepAlive => false;
}
